package com.shihb.structuralpatterns.compositepattern;

import java.util.ArrayList;
import java.util.List;

/**
 *Description:
 *Version:1.0.0
 *@author shihb
 *@date 2020/7/19 21:54
 */
public class College extends Organization{
  /**
   *   把学院组合进来
   */
  List<Organization> departments =new ArrayList<>();

  public College(String name) {
    super(name);
  }

  @Override
  public void add(Organization organization) {
    departments.add(organization);
  }

  @Override
  public void remove(Organization organization) {
    departments.remove(organization);
  }

  @Override
  public String getName() {
    return super.getName();
  }

  @Override
  protected void show() {
    System.out.println("-----"+getName()+"--------");
    for(Organization department: departments){
      department.show();
    }

  }
}
